home *** CD-ROM | disk | FTP | other *** search
-
- #include <intuition/gadgetclass.h>
- #include <libraries/gadtools.h>
- #include <dos/dos.h>
-
- #include <clib/intuition_protos.h>
- #include <clib/gadtools_protos.h>
- #include <clib/exec_protos.h>
- #include <clib/alib_protos.h>
- #include <clib/dos_protos.h>
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #include "project.h"
-
- BOOL KeepMessages;
-
- struct List *MessList=NULL;
- struct MessNode *TopMess;
- long TopM;
-
- struct MessNode {
- struct Node node;
- char *mess;
- };
-
- void FreeMess( void ) {
- struct MessNode *mn,*on;
-
- if ( MessList ) {
- mn = MessList->lh_Head;
- while( on = mn->node.ln_Succ ) {
- free( mn->mess );
- Remove( (struct Node *)mn );
- free( mn );
- mn = on;
- }
- free( MessList );
- MessList = NULL;
- }
- }
-
- void NewMess( void ) {
- MessList = malloc( sizeof(struct List) );
- NewList( MessList );
- }
-
- void AddMess( char *mess ) {
- struct MessNode *mn = malloc( sizeof(struct MessNode) );
-
- mn->mess = strdup( mess );
- mn->node.ln_Name = mn->mess;
- AddTail( MessList , (struct Node *)mn );
- }
-
- void DettachMess( void ) {
- GT_SetGadgetAttrs( MessGadgets[0] , MessWnd , NULL , GTLV_Labels , 0 , TAG_DONE );
- }
-
- void AttachMess( void ) {
- GT_SetGadgetAttrs( MessGadgets[0] , MessWnd , NULL , GTLV_Labels , (long)MessList , TAG_DONE );
- }
-
- BOOL CheckError( char *file ) {
- struct FileInfoBlock fib;
- char temp[200];
- FILE *in;
-
- KeepMessages = TRUE;
- if ( ( GetInfo( &fib , file )) && fib.fib_Size ) {
- if ( !MessWnd ) {
- OpenMessWindow( );
- AddWinC( MessWnd , HandleMessIDCMP );
- }
- WindowToFront( MessWnd );
- if ( CompileWnd )
- WindowToFront( CompileWnd );
- DettachMess( );
- if ( !MessList )
- NewMess( );
- in = fopen( file , "r" );
- fgets( temp , 200 , in );
- while( !feof( in ) ) {
- if ( strstr( temp , "Error" ) || strstr( temp , "Fatal" ) )
- KeepMessages = FALSE;
- temp[ strlen(temp)-1 ] = 0;
- AddMess( temp );
- fgets( temp , 200 , in );
- }
- fclose( in );
- AttachMess( );
- return( TRUE );
- }
- return( FALSE );
- }
-
- BOOL ViewErrors( char *file ) {
- char *file2;
-
- TopM = 0;
- if ( !KeepMessages ) {
- if ( MessWnd )
- DettachMess( );
- FreeMess( );
- NewMess( );
- if ( MessWnd )
- AttachMess( );
- KeepMessages = TRUE;
- }
- if ( !CheckError( file ) ) {
- file2 = strdup( file );
- file2[ strlen(file2)-1 ] = 0;
- CheckError( file2 );
- free( file2 );
- }
- if ( KeepMessages )
- return( FALSE );
- return( TRUE );
- }
-
- int MessListClicked( void )
- {
- }
-
- void UpDateTopMessage( void ) {
- GT_SetGadgetAttrs( MessGadgets[0] , MessWnd , NULL , GTLV_Top , TopM , TAG_DONE );
- }
-
- int MessCloseWindow( void )
- {
- if ( MessWnd ) {
- DettachMess( );
- FreeMess( );
- RemWinC( MessWnd );
- CloseMessWindow( );
- }
- }
-
- int MessNewSize( void )
- {
- DettachMess( );
- RemWinC( MessWnd );
- CloseMessWindow( );
- OpenMessWindow( );
- AddWinC( MessWnd , HandleMessIDCMP );
- AttachMess( );
- UpDateTopMessage( );
- }
-
- void PrevMessage( void ) {
- if ( !TopMess ) {
- TopMess = MessList->lh_Head;
- TopM = 0;
- while( TopMess->node.ln_Succ->ln_Succ ) {
- TopMess = TopMess->node.ln_Succ;
- TopM ++;
- }
- } else {
- if ( TopMess->node.ln_Pred->ln_Pred ) {
- TopMess = TopMess->node.ln_Pred;
- TopM --;
- }
- }
- UpDateTopMessage( );
- }
-
- void NextMessage( void ) {
- if ( !TopMess ) {
- TopMess = MessList->lh_Head;
- TopM = 0;
- } else {
- if ( TopMess->node.ln_Succ->ln_Succ ) {
- TopMess = TopMess->node.ln_Succ;
- TopM ++;
- }
- }
- UpDateTopMessage( );
- }
-
-